package www.openteam.com.ui.prdctnMngmnt;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.AppCompatEditText;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;
import www.openteam.com.R;
import www.openteam.com.bean.SRCKPlanMsg;
import www.openteam.com.bean.SRCPoduMsg;


/**
 * A simple {@link Fragment} subclass.
 */
public class SRCKPoduEditFragment extends Fragment {


    @Bind(R.id.SRCKPd_pjctNum)
    TextView SRCKPdPjctNum;
    @Bind(R.id.SRCKPd_pjctCode)
    TextView SRCKPdPjctCode;
    @Bind(R.id.SRCKPd_pjctName)
    TextView SRCKPdPjctName;
    @Bind(R.id.SRCKPd_Unit)
    TextView SRCKPdUnit;
    @Bind(R.id.SRCKPd_parts)
    TextView SRCKPdParts;
    @Bind(R.id.SRCKPd_poduce)
    TextView SRCKPdPoduce;
    @Bind(R.id.SRCKPd_poduceName)
    TextView SRCKPdPoduceName;
    @Bind(R.id.SRCKPd_pjctReq)
    TextView SRCKPdPjctReq;
    @Bind(R.id.SRCKPd_otherState)
    TextView SRCKPdOtherState;
    @Bind(R.id.SRCKPd_amount)
    AppCompatEditText SRCKPdAmount;
    @Bind(R.id.SRCKPd_goodNum)
    AppCompatEditText SRCKPdgoodNum;
    @Bind(R.id.SRCKPd_units)
    Spinner SRCKPdUnits;
    @Bind(R.id.SRCKPd_perPrice)
    AppCompatEditText SRCKPdPerPrice;
    @Bind(R.id.SRCKPd_money)
    TextView SRCKPdMoney;
    @Bind(R.id.SRCKPd_afford)
    AppCompatEditText SRCKPdAfford;
    @Bind(R.id.SRCKPd_address)
    AppCompatEditText SRCKPdAddress;
    @Bind(R.id.SRCKPd_reason)
    AppCompatEditText SRCKPdReason;
    @Bind(R.id.SRCKPd_remake)
    AppCompatEditText SRCKPdRemake;
    @Bind(R.id.SRCKPd_planNo)
    TextView SRCKPdPlanNo;
    @Bind(R.id.SRCK_relate_planNo)
    RelativeLayout SRCKRelatePlanNo;
    private SRCPoduMsg.DataBeanX.DataBean dataBean00;
    private String tag00;
    private SRCKPlanMsg.DataBeanX.DataBean dataBean01;

    public SRCKPoduEditFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_srckpodu_edit, container, false);
        ButterKnife.bind(this, view);
        initdata();
        return view;
    }

    private void initdata() {

        if (tag00.contains("podu") && dataBean00 != null) {
            SRCKRelatePlanNo.setVisibility(View.GONE);
            SRCKPdPjctNum.setText(dataBean00.getPojectNum());
            SRCKPdPjctCode.setText(dataBean00.getPojectCode());
            SRCKPdPjctName.setText(dataBean00.getPojectName());
            SRCKPdUnit.setText(dataBean00.getUnit());
            SRCKPdParts.setText(dataBean00.getGroupname() + "");
            SRCKPdPoduce.setText(dataBean00.getPoduce());
            SRCKPdPoduceName.setText(dataBean00.getPoduceName());
            SRCKPdPjctReq.setText(dataBean00.getPocessReq());
            SRCKPdOtherState.setText(dataBean00.getOtherState());
            SRCKPdAmount.setText(dataBean00.getAmount() + "");
            SRCKPdgoodNum.setText(dataBean00.getAmount() + "");
        }

        if (tag00.contains("plan") && dataBean01 != null) {
            SRCKRelatePlanNo.setVisibility(View.VISIBLE);
            SRCKPdPlanNo.setText(dataBean01.getOsplanrdsno());
            SRCKPdPjctNum.setText(dataBean01.getProduceno());
            SRCKPdPjctCode.setText(dataBean01.getCode());
            SRCKPdPjctName.setText(dataBean01.getProcname());
            SRCKPdUnit.setText(dataBean01.getGroupname());
            SRCKPdParts.setText(dataBean01.getPartid() + "");
            SRCKPdPoduce.setText(dataBean01.getProcno());
            SRCKPdPoduceName.setText(dataBean01.getProcname());
            SRCKPdPjctReq.setText(dataBean01.getProcremark());
            SRCKPdOtherState.setText(dataBean01.getOtherremark());
            SRCKPdAmount.setText(dataBean01.getAllsum() + "");
            SRCKPdgoodNum.setText(dataBean01.getAllsum() + "");
        }
    }

    public void getdata00(SRCPoduMsg.DataBeanX.DataBean dataBean, String tag) {
        tag00 = tag;
        dataBean00 = dataBean;
    }

    public void getdata01(SRCKPlanMsg.DataBeanX.DataBean dataBean, String tag) {
        tag00 = tag;
        dataBean01 = dataBean;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
